/*
 * @Author: gyc
 * @Date: 2020-05-26 13:18:40
 * @LastEditTime: 2020-08-25 09:19:34
 * @Description: Nuxt测试版
 */
/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
	/**
	 * built-in config
	 * @type {Egg.EggAppConfig}
	 **/
	const config = exports = {};

	config.mysql = {
		// 单数据库信息配置
		client: {
			// host
			host: '47.100.35.97',
			// 端口号
			port: '3306',
			// 用户名
			user: 'yui',
			// 密码
			password: '1997629gan.',
			// 数据库名
			database: 'yui',
		},
		// 是否加载到 app 上，默认开启
		app: true,
		// 是否加载到 agent 上，默认关闭
		agent: false
	}

	// use for cookie sign key, should change to your own and keep security
	config.keys = appInfo.name + '_1590470307990_3595';

	// add your middleware config here
	config.middleware = [];

	config.proxy = true;
	config.cluster = {
		listen: {
			path: '',
			port: 7001,
			hostname: '127.0.0.1', //localhost
		}
	};

	//跨域白名单
	config.security = {
		csrf: {
			enable: false,
			ignoreJSON: true
		},
		domainWhiteList: ['http://localhost:3000']
	};

	//跨域
	config.cors = {
		origin: 'http://localhost:3000',
		allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
		credentials: true,
	};


	//redis
	config.redis = {
		client: {
			port: 6379, // Redis port
			host: '47.100.35.97', // Redis host
			password: '199700',
			db: 0,
		},
	}

	//sokect
	exports.io = {
		init: {}, // passed to engine.io
		namespace: {
			'/': {
				connectionMiddleware: ['auth'],
				packetMiddleware: ['filter'],
			},
			'/example': {
				connectionMiddleware: [],
				packetMiddleware: [],
			},
		},
		redis: {
			host: "47.100.35.97",
			port: "6379",
			auth_pass: "199700",
			db: 0,
		},
	};

	exports.multipart = {
		mode: 'file',
	}

	config.session = {
		key: 'SESSION_ID', // 设置session cookie里面的key
		maxAge: 1000 * 3600 * 24 * 7, // 设置过期时间
		httpOnly: true,
		encrypt: true,
		renew: true // renew等于true 那么每次刷新页面的时候 session都会被延期
	}

	config.passportLocal = {
		usernameField: 'username',
		passwordField: 'password',
	}
	// add your user config here
	const userConfig = {
		// myAppName: 'egg',
	};

	return {
		...config,
		...userConfig,
	};
};